import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import dataManage from '../views/dataManage.vue'
import feedback from '@/components/feedback/feedback.page.vue'
import login from '@/components/login/login.page.vue'
import index from '@/views/index.vue'
import caseManage from "@/views/caseManage.vue";
import indexManage from "@/views/indexManage.vue";
import vipManage from "@/views/vipManage.vue";
import publicizeManage from "@/views/publicizeManage.vue";
import activeInterception from "@/views/activeInterception.vue";
import riskSourceStationAnalysis from "@/components/riskSourceStationAnalysis/riskSourceStationAnalysis.vue";
import interceptList from "@/views/interceptList.vue";
import daPing from "@/views/daPing.vue";
import victimManage from "@/views/victimManage.vue";
import precisePreventManage from "@/views/precisePreventManage.vue";
import streetPrecaution from "@/views/streetPrecaution.vue";
import aiDiscouragement from "@/components/aiDiscouragement/aiDiscouragement.vue";
import aiImportData from "@/components/aiImportData/index.vue";
import aiTable from "@/components/aiTable/aiTable.vue";
import aiPage from "@/views/ai.vue";
import caseinf from "@/components/caseinf/list.vue";
import caseDetail from "@/components/caseinf/caseDetail.vue";

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        name: 'Home',
        redirect: '/index',
        component: Home,
        children: [
            {
                path: '/index',
                name: 'index',
                component: index
            },
            {
                path: '/dataManage',
                name: 'dataManage',
                component: dataManage
            }, {
                path: '/caseManage',
                name: 'caseManage',
                component: caseManage
            }, {
                path: '/indexManage',
                name: 'indexManage',
                component: indexManage
            }, {
                path: '/vipManage',
                name: 'vipManage',
                component: vipManage
            },
            {
                path: '/publicizeManage',
                name: 'publicizeManage',
                component: publicizeManage
            },
            {
                path: '/activeInterception',
                name: 'activeInterception',
                component: activeInterception
            },
            {
                path: '/riskSourceStationAnalysis',
                name: 'riskSourceStationAnalysis',
                component: riskSourceStationAnalysis
            },
            {
                path: '/interceptList',
                name: 'interceptList',
                component: interceptList
            },
            // {
            //     path: '/ai',
            //     name: 'ai',
            //     component: ai
            // },
            {
                path: '/daPing',
                name: 'daPing',
                component: daPing
            },
            {
                path: '/victimManage',
                name: 'victimManage',
                component: victimManage
            },
            {
                path: '/precisePreventManage',
                name: 'precisePreventManage',
                component: precisePreventManage
            },
            {
                path: '/streetPrecaution',
                name: 'streetPrecaution',
                component: streetPrecaution
            },
            {
                path: '/aiPage',
                name: 'ai',
                component: aiPage,
                redirect: '/aiPage/aiDiscouragement',
                children: [
                    {
                        path: '/aiPage/aiDiscouragement',
                        name: 'aiDiscouragement',
                        component: aiDiscouragement
                    },
                    {
                        path: '/aiPage/aiImportData',
                        name: 'aiImportData',
                        component: aiImportData
                    },
                ]
            },

        ]
    },
    {
        path: '/model/feedback',
        name: 'feedback',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: feedback
    },
    {
        path: '/aiTable',
        name: 'aiTable',
        component: aiTable
    },
    {
        path: '/caseinf',
        name: 'caseinf',
        component: caseinf
    },
    {
        path: '/caseDetail',
        name: 'caseDetail',
        component: caseDetail
    },
    {
        path: '/login',
        name: 'login',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: login
    },
]
const router = new VueRouter({
    routes
})
router.beforeEach((to, from, next) => {
    let usr = window.sessionStorage.getItem('usr')
    if(!usr && to.name !== 'login'){
      next('/login');
    }else{
      next()
    }
    // next()

})
export default router
